package cn.doit.scala.day04

/**
 * @DATE 2021/12/28/10:13
 * @Author MDK
 * @Version 2021.2.2
 * */
object C05_ReduceRight {
  def main(args: Array[String]): Unit = {
    val  list = List(1,2,4,5)
    // (x1,x2)=>x1-x2   x1 一定在x2的左边
    list.reduceLeft((x1,x2)=>x1-x2)
    list.reduceRight((x1,x2)=>x1-x2)
    val res: Int = list.reduceRight(_ - _)
    println(res)

    val arr = Array[String]("a" , "b","c","d","e")
    println(arr.reduceRight(_ + ":" + _))
  }
}
